package org.sam.swing.utils;

import java.awt.Color;

/**
 * 颜色相关的工具类
 * @author sam
 *
 */
public class ColorUtil {
	public static String Color2String(Color color) {
		String r, g, b;
		StringBuilder su = new StringBuilder();
		r = Integer.toHexString(color.getRed());
		g = Integer.toHexString(color.getGreen());
		b = Integer.toHexString(color.getBlue());
		r = r.length() == 1 ? "0" + r : r;
		g = g.length() == 1 ? "0" + g : g;
		b = b.length() == 1 ? "0" + b : b;
		r = r.toUpperCase();
		g = g.toUpperCase();
		b = b.toUpperCase();
		su.append("0xFF");
		su.append(b);
		su.append(g);
		su.append(r);
		return su.toString();
	}
}
